<?php
namespace app\admin\controller;
use think\Db;//导入数据库类 (DB类)
use think\Controller;
class Node extends Admin
{


	//管理员设置
	public function index()
    {
    	$data=db('node')->paginate(10);
      $page = $data->render();
    	$this->assign('data',$data);
      $this->assign('page',$page);
      return view('Jurisdiction/node');
        
    }
  public function del()
    {
        $data=db('node')->where('id',input('id'))->delete();
        if ($data>0) {
          $this->success('删除成功');
        }else{
          $this->error('删除失败');
        }
    }

  public function edit()
    {
        $data=db('node')->where('id',input('id'))->find();
        $this->assign('data',$data);
        return view('Jurisdiction/nodeedit');     
   
    }

    public function doedit()
   {
    if (empty(input('name')&&input('mname')&&input('aname'))) {
              $this->error('输入信息有误');
          }
          $data = ['name' =>input('name'), 'mname' => input('mname'),'aname' => input('aname')];
          $rus=db('node')->where('id',input('id'))->update($data);
          if ($rus>0) {
              $this->success('修改成功');
          }else{
              $this->error('错误');
          }
   }
    public function add()
    {
       
        return view('Jurisdiction/nodeadd');     
   
    }

    public function doadd()
    {
       
       if (empty(input('name')&&input('mname')&&input('aname'))) {
              $this->error('输入信息有误');
      }
        $data = ['name' =>input('name'), 'mname' => input('mname'),'aname' => input('aname')];
           $rus=db('node')->insert($data);
           if ($rus>0) {
              $this->success('新增成功');
          }else{
              $this->error('新增失败');
          }
    }

}	
